package com.day0426.door;/*
 * @创建者：黄苟苟
 * @创建时间：2021/4/26   11:31
 * @Description描述
 **/

import com.day0426.validate.CardVld;
import com.day0426.validate.FingerMark;
import com.day0426.validate.PassWordVld;
import com.day0426.validate.Validate;

public class Computer {
    private String[] passWord = new String[100];
    private String[] card = new String[100];
    private String[] fingerMark = new String[100];
    /*
     * 无参构造法初始化密码相关
     * */

    public Computer() {
        passWord[0] = "2222";
        card[0] = "supername";
        fingerMark[0] = "supername";
    }

    /*
     * 验证相关信息
     * */
    public boolean validate(String passStr) {
        Validate validate = null;
        String prefix = passStr.substring(0, 2);
        /*验证密码*/
        if (prefix.equals("pa")) {
            validate = new PassWordVld(passWord, passStr);
            return validate.check();
        } else if (prefix.equals("ca")) {
            validate = new CardVld(card, passStr);
            return validate.check();

        } else if (prefix.equals("fi")) {
            validate = new FingerMark(fingerMark, passStr);
            return validate.check();
        } else {
            return false;
        }
    }
    public void addCard(String card){
        for (int i = 0; i <100 ; i++) {
            if (this.card[i]==null){
                this.card[i]=card;
                return;
            }
        }
    }
    public void addFingerMark(String fingerMark){
        for (int i = 0; i <100 ; i++) {
            if (this.fingerMark[i]==null){
                this.fingerMark[i]=fingerMark;
                return;
            }
        }
    }
    public void addPassWord(int passWord){
        for (int i = 0; i <100 ; i++) {
            if (this.passWord[i]==null){
                this.passWord[i]=passWord*2+"";
                return;
            }
        }
    }


    /*
     * set/get方法
     *
     * */
    public String[] getPassWord() {
        return passWord;
    }

    public void setPassWord(String[] passWord) {
        this.passWord = passWord;
    }

    public String[] getCard() {
        return card;
    }

    public void setCard(String[] card) {
        this.card = card;
    }

    public String[] getFingerMark() {
        return fingerMark;
    }

    public void setFingerMark(String[] fingerMark) {
        this.fingerMark = fingerMark;
    }
}
